Magnetic stripe reader sample


Windows Runtime
Devices and sensors, Point of service
Windows RT
en-US
11/25/2013

This sample shows how to create a magnetic stripe reader, claim it for exclusive use, enable it to receive data, and read data from a bank card or a motor vehicle card. This sample uses Windows.Devices.PointOfService API.

This sample demonstrates these tasks:

  1. Get the magnetic stripe reader

    Uses the MagneticStripeReader.GetDefaultAsync method to get the first available magnetic stripe reader.

  2. Claim the magnetic stripe reader for exclusive use

    Uses ClaimReaderAsync to claim the device.

  3. Add event handlers

    Uses BankCardDataReceived, AamvaCardDataReceived, and ReleaseDeviceRequested events.

    When an application gets a request from another application to release its exclusive claim to the magnetic stripe reader, it must handle the request by retaining the device; otherwise, it will lose its claim. The event handler for ReleaseDeviceRequested shows how to do this.

  4. Enable the device to receive data

    Uses EnableAsync.

The app package manifest shows how to specify the device capability name for the Point of Service (POS) devices. All POS apps are required declare DeviceCapability in the app package manifest, either by using "PointofService" as shown in this sample or by using device specific GUID, such as "2A9FE532-0CDC-44F9-9827-76192F2CA2FB" for a magnetic stripe reader.

The following list shows the magnetic stripe readers that were used with this code sample:

  • MagTek MagneSafe HID USB reader (VID 0801, PID 0011)
  • MagTek SureSwipe HID USB reader ( VID 0801, PID 0002)
  • MagTek BulleT Bluetooth/USB reader, when connected via USB (VID 0801, PID 0011)
  • ID TECH SecureMag HID USB reader (VID 0ACD, PID 2010)
  • ID TECH MiniMag HID USB reader (VID 0ACD, PID 0500)

Note  For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft Visual Studio 2012.

Related topics

Barcode Scanner Sample
Windows.Devices.PointOfService
Windows app samples

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2

Build the sample

  1. Start Visual Studio 2013 and select File > Open > Project/Solution.
  2. Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Visual Studio 2013 Solution (.sln) file.
  3. Press F7 or use Build > Build Solution to build the sample.

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.